<?php

require 'autoload.php';

class Constructor
{
    protected $builder;
    public function __construct( Constructor\IBuilder $builder = NULL )
    {
        if( is_null( $builder ) ) 
        {
            $createBuilder = function()
            {
                return new Constructor\Builder
                ( 
                    new Constructor\Instances
                    ( 
                        new Constructor\Factory(),
                        new Constructor\Container() 
                    ) 
                );
            };
            
            $this->builder = $createBuilder();
        }
        else $this->builder = $builder;
    }
    
    public function get( $identifier = NULL ) { return $this->builder->get( $identifier ); }
    public function set( $instance, $identifier = NULL ) { return $this->builder->set( $instance, $identifier ); }
    public function has( $identifier ) { return $this->builder->has( $identifier ); }
    
    public function create( $identifier ) { return $this->builder->create( $identifier ); }
    public function register( $alias, $identifier = NULL ) { $this->builder->register( $alias, $identifier ); }
    public function getAlias( $identifier = NULL ) { return $this->builder->getAlias( $identifier ); }
    
    public function reset() { $this->builder->reset(); }
    public function count() { return $this->builder->count(); }
    public function getIdentifiers() { return $this->builder->getIdentifiers(); }
}
